package com.demo.consumer.controller.demoinfo;

import com.demo.consumer.controller.apm.ApmDeomController;
import com.demo.consumer.service.RiskServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

@RestController
@Slf4j
public class GetDemoInfo {

    @Value("${stock_provider_url}")
    String stockProviderUrl;


//    String url = "http://127.0.0.1:10001/instance/info";

    @Autowired
    RestTemplate restTemplate;

    @Autowired
    RiskServiceImpl riskService;

    private static final Logger log = LoggerFactory.getLogger(GetDemoInfo.class);

    @GetMapping("demoinfo")
    public String demoInfo() {

        String url = stockProviderUrl+"/instance/info";
        String response =  restTemplate.getForObject(url, String.class);
        log.info("/demoinfo 调用provider:/instance/info {}", response);
        return  response;
    }

    @GetMapping("serviceinfo")
    public String riskService() {
        String response = riskService.risk();
        log.info("/serviceinfo {}",response);
        return response;

    }



}
